
public class SingletonIodh {
    //1 私有化构造函数
    private SingletonIodh(){}
    //2 静态内部类中创建单实例对象
    private static  class SingletonHolder{
        private static final SingletonIodh instance = new SingletonIodh();
    }
    //3 提供公共方法
    public static final SingletonIodh getInstance(){
        return SingletonHolder.instance;    
    }  
    
    
    public static void main(String[] args) {
        //验证是否返回同一实例
        SingletonIodh s1 =  SingletonIodh.getInstance();
        SingletonIodh s2 =  SingletonIodh.getInstance();
        System.out.println(s1==s2);
    }
}